<style>
.venue_salse{
	width: 111px!important;
    text-decoration: none!important;
    font-weight: bold!important;
}
.fieldlist dd ins {
    width: 111px!important;
 
}
</style>
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="" autocomplete="off">


    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('School.Season_id')}:</label>
        <div class="col-xs-12 col-sm-8">
           <input id="c-season_time" data-rule="required" class="form-control"  disabled  name="row[name]" type="text" value="{$row.name}"> 
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Season.Season_time')}:</label>
        <div class="col-xs-12 col-sm-8">
		<input id="c-season_time" data-rule="required" class="form-control"  disabled  name="row[name]" type="text" value="{$row.season_time}" >
        </div>
    </div>
	<div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Sales.info')}:</label>
        <div class="col-xs-12 col-sm-8">
		   <dl class="fieldlist" data-name="data[type]" data-template="venue_tpl">
				<dd>
					<ins>{:__('Sales.type')}</ins>
					<ins>{:__('Pricing.type')}</ins>
					<ins>{:__('Pricing.price')}</ins>
					<ins>{:__('Sales.price')}</ins>
					<ins>{:__('Pricing.num')}</ins>
					<ins>{:__('Round.num')}</ins>
					<ins>{:__('Desc')}</ins>
				</dd>
				<dd><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('Append')}</a></dd>
				<textarea name="data[type]" class="form-control hide" cols="30" rows="5">{$WeekInfo['SalesInfo']}</textarea>
			</dl>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Desc')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-desc" class="form-control  form-control" rows="5" name="row[desc]" cols="50">{$row.desc}</textarea>
        </div>
    </div>
   
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
        </div>
    </div>
</form>
<div style="display: none;">
				<input type="text"  class="form-control defauftid  " id="defauftid"   size="10"> 
</div>
<script type="text/html" id="venue_tpl">
    <dd class="form-inline">
	    <select class="form-control venue_salse sales_type_<%=index%> "  name="data[type][<%=index%>][sales_type]" >
		 {foreach name="$WeekInfo['RoundInfo']['Sales_type']" key="sales_type" item="sales_vo"}
			<option value="{$sales_type}"  >{$sales_vo['name']}</option>
		 {/foreach}
		</select>
		<input type="text"  class="form-control sales_type_name_<%=index%> hide " value="<%=row.value.sales_type%>" size="10"> 

	    <select class="form-control venue_salse pricing_type pricing_type_<%=index%>" attrv="<%=index%>" attrite="pricing_type_<%=index%>"  name="data[type][<%=index%>][pricing_type]" >
		 {foreach name="$WeekInfo['RoundInfo']['Pricing_type']" key="pricing_type" item="pricing_vo"}
			<option value="{$pricing_type}"  >{$pricing_vo}</option>
		 {/foreach}
		</select>
		<input type="text"  class="form-control pricing_type_name_<%=index%> hide " value="<%=row.value.pricing_type%>" size="10"> 

	    <select class="form-control venue_salse pricing_price1_<%=index%>"   name="data[type][<%=index%>][pricing_price1]" >
		 {foreach name="$WeekInfo['RoundInfo']['Pricing_price']" key="Pricing_price" item="pricing_price_vo"}
			<option value="{$pricing_price_vo}"  >{$pricing_price_vo}</option>
		 {/foreach}
		</select>
		<input type="text"  class="form-control venue_salse  pricing_price1_name_<%=index%> hide " value="<%=row.value.pricing_price%>" size="10"> 

		<input type="text" name="data[type][<%=index%>][pricing_price2]"  class="form-control venue_salse  pricing_price2_<%=index%> hide" value="<%=row.value.pricing_price%>" size="10"> 
		<input type="text" name="data[type][<%=index%>][sales_price]"  class="form-control venue_salse  sales_price" value="<%=row.value.sales_price%>" size="10"> 
		<input type="text" name="data[type][<%=index%>][pricing_num]" attrite="pricing_num_<%=index%>" class="form-control venue_salse  pricing_num" value="<%=row.value.pricing_num%>" size="10"> 
		<input type="text" name="data[type][<%=index%>][round_num]"  class="form-control venue_salse  round_num_<%=index%>" value="<%=row.value.round_num%>" size="10"> 
		<input type="text" name="data[type][<%=index%>][desc]" class="form-control venue_salse desc" value="<%=row.value.desc%>" size="10"> 
		<input type="text" name="data[type][<%=index%>][data]" class="form-control venue_salse desc" value="<%=row.value.data%>"  style="display:none;" id="pricing_data_<%=index%>" >
	
		<span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> 
		<span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span>
		<span class="btn btn-sm btn-success pricing_type_click_<%=index%> pricing_type_click  hide" title="组合定价详情" attrv="<%=index%>"><i class="fa fa-plus"></i></span> 
    </dd>
	//var select = document.querySelector('.dataType_<%=index%>'); 
	//	select.options[3].selected = true;  

</script>
<script type="text/javascript">
window.onload=function(){
	var num = "{$WeekInfo['SalesNum']}";

	setTimeout(function(){
	   if(num > 0){
		for (var i=0;i<num ;i++ ){
			//销售类型
			var sales_value = document.querySelector('.sales_type_name_'+i).value;
			var sales_select = document.querySelector('.sales_type_'+i);
			for(var a=0; a<sales_select.options.length; a++){  
				if(sales_select.options[a].value == sales_value){  
					sales_select.options[a].selected = true; 
				}
			} 
			//定价类型
			var pricing_value = document.querySelector('.pricing_type_name_'+i).value;
			var pricing_select = document.querySelector('.pricing_type_'+i);
			for(var a=0; a<pricing_select.options.length; a++){  
				if(pricing_select.options[a].value == pricing_value){  
					pricing_select.options[a].selected = true; 
				}
			} 
			if(pricing_value == 1){
				//定价类型
				var pricing_price1 = document.querySelector('.pricing_price1_name_'+i).value;
				var pricing_price1_select = document.querySelector('.pricing_price1_'+i);
				for(var a=0; a<pricing_price1_select.options.length; a++){  
					if(pricing_price1_select.options[a].value == pricing_price1){  
						pricing_price1_select.options[a].selected = true; 
					}
				}
			}else{
				addClass(document.querySelector('.pricing_price1_'+i),'hide');
				removeClass(document.querySelector('.pricing_price2_'+i),'hide');
				removeClass(document.querySelector('.pricing_type_click_'+i),'hide');
			}
			
		}
	 }
	},3000); 
	function hasClass(element,cName){        //检查class是否存在
		return !!element.className.match(new RegExp('(\\s|^)'+cName+'(\\s|$)'));
	}
	function addClass(element,cName){        //添加一个class
		if(!hasClass(element,cName)){
			element.className +=' '+cName;
		}
	}
	function removeClass(element,cName){        //移除一个class
		if(hasClass(element,cName)){
			element.className = element.className.replace(new RegExp('(\\s|^)'+cName+'(\\s|$)'),' ');
		}
	}
}

</script>